package com.capgemini.scaffold.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.capgemini.scaffold.dto.FrontDTO;
import com.capgemini.scaffold.entity.Front;
import com.capgemini.scaffold.mapper.FrontMapper;
import com.capgemini.scaffold.service.FrontService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class FrontServiceImpl extends ServiceImpl<FrontMapper, Front> implements FrontService {
    @Resource
    private FrontMapper frontMapper;

    /**
     * 查询用户信息表，入参均为非必填
     *   internName：模糊查询
     *   startTime：CREATE_AT 大于等于 startTime
     *   endTime：CREATE_AT 小于 endTime
     *
     * @param req 查询请求入参对象
     * @return 用户信息列表
     */
    @Override
    public List<Front> queryFront(FrontDTO req) {
        return frontMapper.queryFront(req);
    }

    /**
     * 分页查询用户信息
     *
     * @param req 查询请求入参
     * @return 查询结果
     */
    @Override
    public IPage<Front> findFrontPage(FrontDTO req) {
        //封装分页信息，第一个参数页码值、第二个参数每页显示数量
        Page<Front> page = new Page<>(req.getPageNum(), req.getPageSize());
        //进行分页查询
        IPage<Front> pageList = frontMapper.findFront(page, req);
        //获取分req
        return pageList;
    }
}
